package com.eric.demo;

/**
 * @author guangyin.zhang
 * @since 2020/1/16
 */
public class DiGui {

    public static void main(String[] args){
        DiGui diGui = new DiGui();
        System.out.println(diGui.fun(4));
    }

    private int fun(int n){
        if(n <= 0){
            throw new RuntimeException("参数错误，n>0");
        }
        if(n == 1){
            return 1;
        }else if(n == 2){
            return 2;
        }else if(n == 3){
            return 1 + 2 + 1;
        }else{
            return fun(n-1) + fun(n-2) + fun(n-3);
        }
    }
}
